/**
 * $Id: Genre.java 20 2006-09-16 20:32:08Z willi.w $
 */
package at.wwu.tunes2db.types;

import java.util.Hashtable;

import org.apache.log4j.Logger;


/**
 * @author willi.w
 * Genre information
 */
public class Kind extends Element {
    private static final Logger log = Logger.getLogger(Kind.class.getName());

    private static final Hashtable<String, Kind> kinds = new Hashtable<String, Kind>();

    private Kind(String new_name) {
        super(new_name);
    }

    public static Kind add(String name) {
        
        if (kinds.containsKey(name.trim())) {
            instance = kinds.get(name.trim());
            instance.isNew = false;
        } else {
            instance = new Kind(name.trim());
            instance.isNew = true;
            kinds.put(name.trim(), (Kind) instance);
            log.debug("Kind.add("+ (instance.isNew?"new ":"") + name + ")");
        }        
        return (Kind) instance;
    }

    @Override
    public String toString() {
        return "Kind " + id + ": " + name;
    }
}
